<?php
	// set $_SESSION["userid"] jika berhasil login, return userid-nya
	// jika gagal return -1
	
	function setLogin($user) {
		connect();
		$userlogin = login($user["username"], $user["password"]);
		if ($userlogin["ID_user"]!=-1) {
			$_SESSION["userid"]=$userlogin["ID_user"];
			$_SESSION["username"]=$userlogin["username"];
			$_SESSION["nama_lengkap"]=$userlogin["nama_lengkap"];
			$_SESSION["avatar_path"]=$userlogin["avatar_path"];
			$_SESSION["email"]=$userlogin["email"];
			$_SESSION["gender"]=$userlogin["gender"];
			$_SESSION["about"]=$userlogin["about"];
			$_SESSION["achievement"]=$userlogin["achievement"];
		}
		return $userlogin["ID_user"];
	}
	
	// return true jika user sudah login
	function isLogin() {
		return (isset($_SESSION["userid"]) && $_SESSION["userid"]!=-1);
	}
	
	// mengembalikan userid user yang sudah login
	function getLoginUserid() {
			return $_SESSION["userid"];
	}
	
	function logout() {
		session_start();
		session_destroy();
	}
?>